package cn.itcast.scala
/*
* 	Date:2022.02.27
* 	Author:dong hui
*
* */
object ArrayTraversal {
	def main(args: Array[String]): Unit = {
		var myArr = Array(1.9,2.9,3.4,3.5)
		for(i <- myArr) {
			print(i + " ")
		}
		println()

		var total = 0.0
		for(i <- 0 to (myArr.length -1)) {
			total += myArr(i)
		}
		println("sum = " + total)

		var max = myArr(0)
		for(i <- 1 to (myArr.length -1)) {
			if (myArr(i) > max)
				max = myArr(i)
		}
		println("max = " + max)
	}
}
